package State;

import Factory.AgriculturalMachine;
import java.util.Date;

public class PausedState implements MachineState {
    private AgriculturalMachine machine;
    private Date startTime;

    public PausedState(AgriculturalMachine machine) {
        this.machine = machine;
        this.startTime = new Date();
    }

    @Override
    public void start() {
        System.out.println("机器已暂停，需要先恢复工作");
    }

    @Override
    public void stop() {
        System.out.println("机器从暂停状态停止工作");
        machine.setState(new IdleState(machine));
    }

    @Override
    public void pause() {
        System.out.println("机器已经处于暂停状态");
    }

    @Override
    public void resume() {
        System.out.println("机器恢复工作");
        machine.setState(new WorkingState(machine));
    }

    @Override
    public void execute() {
        System.out.println("机器已暂停，不执行任务");
    }

    @Override
    public String getStateName() {
        return "已暂停";
    }

    @Override
    public String getStateDescription() {
        return "机器工作已暂停，等待恢复";
    }

    @Override
    public Date getStateStartTime() {
        return startTime;
    }

    @Override
    public long getStateDuration() {
        return new Date().getTime() - startTime.getTime();
    }

    @Override
    public String toString() {
        return "暂停";
    }
}
